<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../../js/bootstrap-3.3.7-dist/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="../../../css/footer.css" />
		<link rel="stylesheet" type="text/css" href="../../../css/swiper-3.4.2.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/record_write.css" />

		<script src="../../../js/jquery-2.2.3.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../../js/layer-v3.1.0/layer/layer.js"></script>
		<link href="../../../js/layer-v3.1.0/layer/theme/default/layer.css" />

		<link rel="stylesheet" type="text/css" href="../../../../common/js/bootstrap-3.3.7-dist/css/bootstrap-datatimepicker.4.14.47.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/manager.css" />
		<!--画图插件-->
		<script src="../../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			.foot:nth-child(1) {
				color: #e83023;
			}
		</style>
	</head>

	<body>
		<div id="wrap">
			<div id="main">
				<div id="header">
					<a id="headImg" href="javascript:history.go(-1)"><img class="headImg" src="../../../images/12.png" /></a>
					<p id="headTitle" style="font-size: 16px;">工作日志</p>
					<a id="headRight" href="record_audit.html">日志审核</a>
				</div>
				<div id="content" style="padding-top: 1.2rem;background-color: #FFFFFF;">
					<div class="top">
						<div class="top_tab active_top">日志填写</div>
						<div class="line"></div>
						<div class="top_tab" onclick="joblogSearch()">日志反馈</div>
					</div>
					<div class="top_item1 active_item1">
						<p class="item1_top">今日完成</p>
						<textarea name="subToday" id="subToday" class="today" rows="" cols=""></textarea>
						<p class="item1_top">明日完成</p>
						<textarea name="subTomorrow" id="subTomorrow" class="today" rows="" cols=""></textarea>
						<button id="record_sub">提交日志</button>
					</div>
					<!--日志反馈-->
					<div class="top_item1">
						<div class="item_tabs">
							<div class="form-group" style="float: left;width: 48%;font-size: 12px;height: 33px;margin-bottom: 0px;font-size: 0.2rem;margin-left: 1.5%;">
								<div class="input-group date" id='date1' style="height: 0.555555rem;width: 90%;">
									<!--<input type="text" class="form-control" style="padding-left: 10px;">-->
									<select id="time" onchange="joblogSearch();" class="form-control">
										<option value="">时间</option>
									</select>
								</div>
							</div>
							<div style="width: 50%;float: right;">
								<select id="fankui" onchange="joblogSearch();" class="form-control" style="width: 90%; margin-left: 10px;color: #7d7575;border: 1px solid #ccc;height: 34px;border-radius: 3px;line-height: 34px;">
									<option value="">全部</option>
									<option value="1">已反馈</option>
									<option value="0">未反馈</option>
								</select>
							</div>
						</div>
						<div id="item1_list">

						</div>
					</div>

				</div>
			</div>
			<div id="foot" class="row">
				<a class="foot col-xs-3 col-sm-3" href="../../kaoqin/index2.html">
					<img class="footImg" src="../../../images/guanlixuanzhong.png" />
					<p>管理</p>
				</a>
				<a class="foot col-xs-3 col-sm-3" href="../../coalition/colalition.html">
					<img class="footImg" src="../../../images/lianmengchushi.png" />
					<p>联盟</p>
				</a>
				<a class="foot col-xs-3 col-sm-3" href="../../store/store.html">
					<img class="footImg" src="../../../images/11.png" />
					<p>商城</p>
				</a>
				<a class="foot col-xs-3 col-sm-3" href="../../personage/personIndex.html">
					<img class="footImg" src="../../../images/13.png" />
					<p>我的</p>
				</a>
			</div>
		</div>

	</body>
	<script src="../../../js/bootstrap-3.3.7-dist/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../js/handlebars-v2.0.0.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/record_write.js" type="text/javascript" charset="utf-8"></script>

	<script src="../../../js/rhAdmin.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../js/Chart.addTest.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../../common/js/bootstrap-3.3.7-dist/js/moment-with-locales.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../../../common/js/bootstrap-3.3.7-dist/js/bootstrap-datatimepicker.4.14.47.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(function() {
			joblogSearch();
		})
		var subAccount = "f1450448928"; //提交人账号
		var subId = "subId"; //提交人id
		var subName = "谢艳飞"; //提交人姓名
		var subSection = "技术部"; //提交人部门
		var subDuty = "一部"; //职务
		var backup4 = "666666aa"; //企业id
		//提交日志
		$('#record_sub').click(function() {
			var subToday = $("#subToday").val();
			var subTomorrow = $("#subTomorrow").val();
			$.ajax({
				cache: false,
				type: "PUT",
				url: "http://10.0.47.157:5555/companyapplyfor-service/joblog/sub",
				dataType: "JSON",
				data: {
					"subAccount": subAccount,
					"subId": subId,
					"subName": subName,
					"subSection": subSection,
					"subDuty": subDuty,
					"subToday": subToday,
					"subTomorrow": subTomorrow,
					"checkAccount": "receiveRole",
					"checkName": "receivePerson",
					"backup4": backup4 //企业id
				},
				async: true, //异步、同步
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					alert("网络异常请稍后重试！");
				},
				success: function(data) {
					layer.msg("提交成功");
					setTimeout(function() {
						history.go(-1);
					}, 500)
				}
			});

		})

		//获取已提交的日志
		function joblogSearch() {
			$("#item1_list").empty();
			var urls = "http://10.0.47.157:5555/companyapplyfor-service/joblog/search?pageNum=1&pageSize=10000&subId=" + subId + "&backup4=" + backup4;
			var time = $("#time").val();//时间
			var fankui = $("#fankui").val();//是否已反馈
			if(time != null && time != ""){
				urls += "&time=" + time; 
			}
			if(fankui != null && fankui != ""){
				urls += "&checkStatus=" + fankui; 
			}
			//加时间筛选  传时间后台获取该月信息 
			$.ajax({
				cache: false,
				type: "GET",
				url: urls,
				dataType: "JSON",
				async: false,
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					alert("网络异常请稍后重试！");
				},
				success: function(data) {
					var item1_list = '<ul><li><a href="javascript:void(0)"><p style="font-weight: bold;">工作日志</p><p style="font-weight: bold;">状态</p><p style="font-weight: bold;">时间</p></a></li>';
					for(var i = 0; i < data.joblogList.list.length; i++) {
						var list = data.joblogList.list[i];
						var checkStatus;
						switch(list.checkStatus) {
							case "0":
								checkStatus = "待反馈";
								break;
							case "1":
								checkStatus = "已反馈";
								break;
							default:
								checkStatus = "-";
								break;
						}
						item1_list += '<li style="font-size: 14px;"><a href="record_details2.html?id=' + list.id + '"><p>工作日志</p><p>' + checkStatus + '</p><p>' + (new Date(list.subDate)).Format("yyyy-MM-dd") + '</p></a></li>';
					}
					item1_list += '</ul>'
					$("#item1_list").append(item1_list);
				}
			});
		}
		Date.prototype.Format = function(fmt) { //author: meizz 
			var o = {
				"M+": this.getMonth() + 1, //月份 
				"d+": this.getDate(), //日 
				"h+": this.getHours(), //小时 
				"m+": this.getMinutes(), //分 
				"s+": this.getSeconds(), //秒 
				"q+": Math.floor((this.getMonth() + 3) / 3), //季度 
				"S": this.getMilliseconds() //毫秒 
			};
			if(/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
			for(var k in o)
				if(new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
			return fmt;
		}

		var date = new Date(); // new 一个Date对象
		var year = date.getFullYear(); // 年份
		var month = date.getMonth() + 1; // 月份（从0开始，所以应+1）
		var r = date.getDate();
		var a;
		for(var i = month; i > month - 12; i--) {
			if(i == 0) {
				a = 12;
				year -= 1
			} else {
				if(i < 10) {
					a = "" + 0 + i
				} else {
					a = i;
				}
			}
			$('<option value="' + year + '-' + a + '-' + r + '">' + year + "年" + a + "月" + "</option>").appendTo($("#time")); // 依次添加下拉框选项，value自定义，右边的appendTo参数为目标选择框
		}
	</script>

</html>